using System;
using System.Collections.Generic;

namespace My.Blog.Web
{
    public class BlogCommonUI
    {
        public static string Header()
        {
            return @"
    <div style='border:1px solid #999;border-top:none;'>
    <span><a href='{RootUrl}/List.aspx'>博客列表</a></span>
    <!--<If:Logon>-->
    <span><a href='{RootUrl}/ArticleList.aspx'>{Owner}的博客</a></span>
    <span><a href='{RootUrl}/Login.aspx?Op=LogoutUser'>退出</a></span>
    <!--</If:Logon>-->
    
    <!--<IfNot:Logon>-->
    <a href='{RootUrl}/Login.aspx'>登录</a>
    <!--</IfNot:Logon>-->

    <!--<If:BlogMaster>-->
        <!--<If:Maintain>-->
        <span style='float:right'><a href='{Query}&Op=ExitMasterMode'>退出管理</a></span>
        <!--</If:Maintain>-->
        
        <!--<IfNot:Maintain>-->
        <span style='float:right'><a href='{Query}&Op=EntryMasterMode'>进入管理</a></span>
        <!--</IfNot:Maintain>-->
    <!--</If:BlogMaster>-->
</div>";
        }

        public static string PrivateHeader()
        {
            return @"
    <div>
        <h1>{Name}</h1>
        <h3>{Declaration}</h3>
    </div>
    <div id='logo'><h1>李娅</h1></div>
    <div id='nav'>
    <p>
        <a href='{RootUrl}/index.aspx' class='active'>Home</a>
        <a href='{RootUrl}/photo.aspx'>Photos</a>
        <a href='{RootUrl}/about.aspx'>About me</a>
        <a href='{RootUrl}/list.aspx?cat_id=2'>Work</a>
        <a href='{RootUrl}/guestbook.aspx'>GuestBook</a>
    </p>
    </div>
    
    <script type='text/javascript'>
        // 突出显示导航的当前项
        function navListener() {
            // 获取导航条对应数组
            var nav = document.getElementById('nav');
            nav = nav.getElementsByTagName('a');

            // 当前元素
            var curEl = location.href.toLowerCase();
            var curIdx = 0;

            // 历遍 navs
            for (var i = 0; i < nav.length; i++) {
                nav[i].className = '';
                if ('' != curEl && 0 <= curEl.indexOf(nav[i].href.toLowerCase()))
                { curIdx = i; }
            }

            nav[curIdx].className = 'active';
        }
        // 调用
        $(function () { navListener(); });
    </script>";
        }

        public static string Breadcrumb()
        {
            return @"
<span class='link'><a href='Index.aspx' title='首页'>首页</a></span>

<!--<If:Empty>-->
<span class='divider'>&gt;</span>
<span class='target' title='当前博客'>博客</span>    
<!--</If:Empty>-->

<!--<IfNot:Empty>-->
    <!--<Loop:List>-->
        <span class='divider'>&gt;</span>
        <span class='link'><a href='ArticleList.aspx?{Id}' title='{Title}'>{Title}</a></span>
    <!--</Loop:List>-->
<!--</IfNot:Empty>-->

<!--<If:ArticleDetail>-->        
<span class='divider'>&gt;</span>
<span class='target'>文章详细</span>
<!--</If:ArticleDetail>-->";
        }

        public static string Footer()
        {
            return @"
<p>© 2008 Design</p>

<script type='text/javascript'>
(function(){
    var today = new Date();
    
    document.write( today.getFullYear()
                  + '-' + today.getMonth()
                  + '-' + today.getDate()
                  + ' ' + today.getHours()
                  + ':' + today.getMinutes()
                  + ':' + today.getSeconds()  );
})();

</script>";
        }

        public static string LogonMenu()
        {
            return @"
<div>
<% 
    if (SecurityUI.IsLogon())
    {
        Response.Write(User.Identity.Name + @'
        <a href='Default.aspx?Module=User&Handler=User&Action=Index'>设置</a>
        <a href='Ajax.aspx?Module=Security&&Handler=Security&Action=LogoutUser'>退出</a>');

        if (SecurityUI.IsMaintainMode('-1'))
        {
            Response.Write(' <a href='Ajax.aspx?Module=User&Handler=Security&Action=ExitMaintainMode'>退出维护模式</a>');
        }
        else
        {
            Response.Write(' <a href='Ajax.aspx?Module=User&Handler=Security&Action=EntryMaintainMode'>进入维护模式</a>');
        }
    }
    else
    {
        Response.Write(' <a href='Default.aspx?Action=Register'>注册</a>');
        Response.Write(' OR ');
        Response.Write(' <a href='Login.aspx?Module=User&Handler=Security&Action=Login'>登录</a>');
    } 
%>
</div>";
        }

        public static string Logon()
        {
            return @"
<input type='hidden' name='Goto' value='<%=Request.UrlReferrer %>' />
<dl>
    <dt>用户名：</dt><dd><input type='text' name='Name' /></dd>
    <dt>密码：</dt><dd><input type='password' name='Password' /></dd>
    <dt></dt><dd><input name='KeepLogon' type='checkbox' value='Yes' />保持登录</dd>
    <dt></dt><dd><button>登录</button></dd>
</dl>";
        }
    }
}